using System.IO;
using System.Reflection;
using HQLAddin.ConfigurationInspector;
using NUnit.Framework;
using SharpTestsEx;

namespace HQLAddin.Tests.Configuration
{
	[TestFixture, Ignore("these tests should be run separately"), Explicit]
	public class ConfigurationTypeProviderTest
	{
		//this project has a reference to NHibernate 3 alpha 2.

		[Test]
		public void WhenThereIsOneNHibernateAssemblyThenConfigurationTypeIsFromThere()
		{
			var type = NhTypes.Configuration;
			type.Should().Be.EqualTo(typeof (NHibernate.Cfg.Configuration));
		}

		[Test]
		public void WhenThereAreTwoNHibernateAssemblyThenConfigurationTypeIsNotFromThere()
		{
			var exampleOutputDir = Path.Combine(Directory.GetCurrentDirectory(), @"..\..\..\Example\Output");
			var assembly = Assembly.LoadFrom(Path.Combine(exampleOutputDir, "NHibernate.dll"));
			var expected = assembly.GetType("NHibernate.Cfg.Configuration");

			var type = NhTypes.Configuration;

			type.Should()
				.Not.Be.Null()
				.And.Be.EqualTo(expected)
				.And.Not.Be.EqualTo(typeof(NHibernate.Cfg.Configuration));
		}
	}
}